package com.TeamJigsaw.DanteTrail.Models;

import java.util.List;
import java.util.Random;


/**
 * A party member recovers from illness.
 * @author Vince
 *
 */
public class RecoverIllnessEvent extends RandomEvent {

	private Random generator;
	
	private String eventMessage;
	
	private List<PartyMember> partyMembers;
	
	public RecoverIllnessEvent (Party party){
		
		generator = new Random();
		eventMessage = null;
		partyMembers = party.getParty();
		
	}
	
	@Override
	public boolean performEvent(Party party) {
		// TODO Auto-generated method stub
		int randNum = generator.nextInt(101);
		int pace = party.getPace();
		double multiply = 0.00;
		if (pace == 5){
			multiply = 1.20;
		}
		else if (pace == 10){
			multiply = 1.15;
		}
		else if (pace == 15){
			multiply = 1.10;
		}
		else if (pace == 20){
			multiply = 1.05;
		}
		
		double newRand = randNum * multiply;
		
		if (newRand > 100){
			randNum = generator.nextInt(3);
			PartyMember currMember = partyMembers.get(randNum);
			if (currMember.getHealth() == 1){
				currMember.setHealth(0);
				eventMessage = currMember.getName() + " is feeling a lot better. " + currMember.getName() + " is no longer sick.";
				return true;
			}
		}
		
		return false;
	}

	@Override
	public String getMessage() {
		// TODO Auto-generated method stub
		return eventMessage;
	}

}
